package gamePlay;


//Player will contain the following items for the game
//1) Name
//2) Number of permanent chips they have
//3) Number of games chips they have
//4) current score
//5) current bet
//6) bet ratio
//7) current answer to question

//Enzo: created multiple class variables as a plan in the future
//so that it could be easily accessible from the GUI standpoint


public class Player {
	private String player_name;
	private int permanent_chips;
	private int game_chips;
	private int curr_score;
	private int curr_bet;
	private long bet_ratio;
	private String curr_answer;
	protected Game currentGame;
	
	//default constructor, no assignments
	public Player(){
		
	}
	
	public Player(String name){
		player_name = name;
		permanent_chips = 2;
		game_chips = 0;
	}
	//constructor that assigns in player_name, permanent_chips to it
	public Player(String player_name, int permanent_chips){
		this.player_name = player_name;
		this.permanent_chips = permanent_chips;
		game_chips = 0;
		curr_score = 0;
		curr_bet = 0;
		bet_ratio = 0;
	}

	public void placeBet(int choice, int chips, boolean chipType){
		if(chips > game_chips + permanent_chips){
			chips = game_chips + permanent_chips;
		}
		// (Anthony) had to change to get rid of an error message, 
		// this should probably be re-evaluated.
		Bet bet = new Bet(player_name, choice, permanent_chips, chips - permanent_chips);
		// if single-player mode:
		currentGame.receiveBet(bet);
		
		// if multi-player mode
		
	}
	
	public void placeBet(int choice, int pChips, int gChips) {
		Bet bet = new Bet("", choice, pChips, gChips);
		currentGame.receiveBet(bet);
	}
	
	public String joinGame(Game g){
		if(g.addPlayer(this)){
			currentGame = g;
			return this.player_name + " has been added to game " + g.getName();
		}
		else
			return this.player_name + " was not added to the game.  " + g.getName() + " is currently full.  Please try a different game.";
	}
	
	public void submitGuess(int num_guess){
		Guess guess = new Guess(player_name, num_guess);
		 currentGame.receiveGuess(guess);
	}
		
	
	//All getters and setters below this comment
	public String getPlayer_name() {
		return player_name;
	}

	public void setPlayer_name(String player_name) {
		this.player_name = player_name;
	}

	public int getPermanent_chips() {
		return permanent_chips;
	}

	public void setPermanent_chips(int permanent_chips) {
		this.permanent_chips = permanent_chips;
	}

	public int getGame_chips() {
		return game_chips;
	}
	
	// Jim Choinoski
	public Game getGame() {
		return currentGame;
	}

	public void setGame_chips(int game_chips) {
		this.game_chips = game_chips;
	}

	public int getCurr_score() {
		return curr_score;
	}

	public void setCurr_score(int curr_score) {
		this.curr_score = curr_score;
	}

	public int getCurr_bet() {
		return curr_bet;
	}

	public void setCurr_bet(int curr_bet) {
		this.curr_bet = curr_bet;
	}

	public long getBet_ratio() {
		return bet_ratio;
	}

	public void setBet_ratio(long bet_ratio) {
		this.bet_ratio = bet_ratio;
	}

	public String getCurr_answer() {
		return curr_answer;
	}

	public void setCurr_answer(String curr_answer) {
		this.curr_answer = curr_answer;
	}
	
	@Override
	public boolean equals(Object o){
		if (o instanceof Player){
			return ((Player)o).player_name.equals(player_name);
		}
		return false;
	}
}